package cn.elricyu.tt.action.secretary;

import net.sf.json.JSON;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.elricyu.tt.action.base.AbstractAction;
import cn.elricyu.tt.bean.ResultStatus;
import cn.elricyu.tt.bean.User;
import cn.elricyu.tt.bean.secretary.MySecretary;
import cn.elricyu.tt.util.JsonUtil;

public class SecretaryAction extends AbstractAction<MySecretary> {
	private static Log logger = LogFactory.getLog(SecretaryAction.class);
	private User self = null;

	public SecretaryAction(User self) {
		this.self = self;
		this.url = "root/secretary.action";
	}

	public void process(JSON json) {
		try {
			int state = JsonUtil.getIntValue(json, "state", 0);
			if (state != ResultStatus.SUCCESS.getCode()) {
				return;
			}
			MySecretary secretary = self.getMySecretary();
			int liid = JsonUtil.getIntValue(json, "liid", 0);
			int lin = JsonUtil.getIntValue(json, "lin", 0);
			int ss = JsonUtil.getIntValue(json, "ss", 0);
			double fp = JsonUtil.getDoubleValue(json, "fp", 0d);
			String name = JsonUtil.getStringValue(json, "name", "");
			int lv = JsonUtil.getIntValue(json, "lv", 0);
			String pic = JsonUtil.getStringValue(json, "pic", "");
			String fun = JsonUtil.getStringValue(json, "fun", "");
			int tasknum = JsonUtil.getIntValue(json, "tasknum", 0);
			int maxtokennum = JsonUtil.getIntValue(json, "maxtokennum", 0);
			long cd = JsonUtil.getLongValue(json, "cd", 0l);
			int tokennum = JsonUtil.getIntValue(json, "tokennum", 0);
			int makenum = JsonUtil.getIntValue(json, "makenum", 0);
			int freer = JsonUtil.getIntValue(json, "freer", 0);
			secretary.setState(state);
			secretary.setLiid(liid);
			secretary.setLin(lin);
			secretary.setSs(ss);
			secretary.setFp(fp);
			secretary.setName(name);
			secretary.setLv(lv);
			secretary.setPic(pic);
			secretary.setFun(fun);
			secretary.setTasknum(tasknum);
			secretary.setMaxtokennum(maxtokennum);
			secretary.setCd(cd);
			secretary.setTokennum(tokennum);
			secretary.setMakenum(makenum);
			secretary.setFreer(freer);
			self.getMyFood().setPrice(fp);
		} catch (Exception e) {
		}
	}

}
